package inheritance;

import java.util.*;

public class MyStack {
	private ArrayList<Object> list = new ArrayList<Object>();
	 	
	public boolean isEmpty() {
		return list.isEmpty();
	}
	 
	public int getSize() {
		return list.size();
	}
	
	public Object peek() {
		return list.get(getSize() - 1);
	}
		
	public Object pop() {
		Object o = list.get(getSize() - 1);
		list.remove(getSize() - 1);
		return o;
	}
		
	public Object push(Object o) {
		list.add(o);
		return o;
	}
		
	public int search(Object o) {
		return list.lastIndexOf(o);
	}
		
	/** Override the toString in the Object class */
	public String toString() {
		return "stack: " + list.toString();
	}
}


